package com.jkhan.demo.ioflow;

import java.io.File;
import java.io.IOException;

/**
 * @ClassName FileTest
 * @Description FileTest
 * @Author hjk
 * @Date 2022/2/12 18:55
 **/
public class FileTest {
    /**
     * 创建File实例
     *
     * @param args
     */
    public static void main(String[] args) {
        File file1 = new File("F:\\文件\\a.txt");
        File file2 = new File("b.txt");

        System.out.println(file1.isFile());
        System.out.println(file2.isFile());

        if (!file2.exists()) {
            try {
                file2.createNewFile();
                System.out.println("创建成功");
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            file2.delete();
            System.out.println("删除成功");
        }
    }
}
